<?php
    require_once './handler/check_session.php';
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head>
        <title>Accueil</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
        <link rel="STYLESHEET" type="text/css" href="style/header_footer_style.css" />
        <link rel="STYLESHEET" type="text/css" href="style/main_style.css" />
    </head>

    <body>
    	<!-- HEADER -->
        <?php include_once './include/header.php'; ?>
        <!-- MAIN -->
		<div id="main">
				<fieldset class="fieldset_section">
					<legend>Contact société</legend>
					<table>                         
						<tr>
							<td class='label'><label for='societe' >Société</label></td>
							<td class='input'><input readonly="readonly" type='text' value='Clement Alexandre SARL'/></td>
						</tr>
						<tr>
							<td class='label'><label for='telephone' >Téléphone</label></td>
							<td class='input'><input readonly="readonly" type='text' value='04 93 52 99 99'/></td>
						</tr>
						<tr>
							<td class='label'><label for='fax' >Fax</label></td>
							<td class='input'><input readonly="readonly" type='text' value='04 89 98 96 42'/></td>
						</tr>
						<tr>
							<td class='label'><label for='email' >Email</label></td>
							<td class='input'><input readonly="readonly" type='text' value='clementcohen@neuf.fr'/></td>
						</tr>
					</table>
				</fieldset>
				<br/><br/>
				<form id='contactmail' action='./handler/contact_send_treatment.php' method='post' accept-charset='UTF-8'>
				<fieldset class="fieldset_section">
				<legend>Demande rapide</legend>
					<table>                         
						<tr>
							<td class='label'><label for='objet' >Nom*</label></td>
							<td class='input'><input type='text' name='nom' id='nom' /></td>
						</tr>
						<tr>
							<td class='label'><label for='objet' >Agence</label></td>
							<td class='input'><input type='text' name='agence' id='agence' /></td>
						</tr>
						<tr>
							<td class='label'><label for='objet' >Email emetteur*</label></td>
							<td class='input'><input type='text' name='email' id='email' /></td>
						</tr>
						<tr>
							<td class='label'><label for='objet' >Sujet*</label></td>
							<td class='input'><input type='text' name='objet' id='objet' /></td>
						</tr>
					</table>
					<table>
						<tr>
							<td class='labelMsg'><label>Message</label><br/>
						 	<textarea rows="5" name='body' id='body' ></textarea></td>
						</tr>
					</table>
				</fieldset>
				<div><br/><input type='button' onclick="javascript:checkFields()" name='valider' value="Envoyer" /></div>
			</form>
		</div>	
		<!-- FOOTER -->
		<?php include_once './include/footer.php';?>
    </body>
</html>
<script>
function checkFields()
{

 var isgood = checkFieldsEmpty();

 if(!isgood)
	 return;

 	document.forms["contactmail"].submit();
 		
	
}

function checkFieldsEmpty()
{
	var listValue = ["nom","email", "objet"];
	var good = true;
	
	for(var i= 0; i < listValue.length; i++)
	{
		var val = listValue[i];
		var fieldValue = document.getElementById(val);

		if(fieldValue.value == null || fieldValue.value == "")
		{
			fieldValue.style.border = 'red 2px solid';
			fieldValue.style.backgroundColor = '#FDF1B8';
			if(good)
				good = false;
		}else{
			fieldValue.style.border = '';
			fieldValue.style.backgroundColor = '';
		}

	}


	if(!good)
	{
		alert("Certains éléments obligatoires sont manquants");
	}

	return good;

}
</script>